<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
	.table-border .ui-jqgrid{
		border: none;
	}
</style>
</head>
<body class="gray-bg">
<div class="container creditbody">
	<div class="iboxtitle">
		<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;业务受理>申请垫资</span>
		<a href="javascript:void(0)"></a>
	</div>
	<div class="tabs-container">
         <ul class="nav nav-tabs">
             <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">按揭日报表数据</a>
             </li>
             <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">申请垫资</a>
             </li>
         </ul>
         <div class="tab-content">
             <div id="tab-1" class="tab-pane active">
                 <div class="panel-body panel-bodyb">
                    <form class="form-horizontal" id="">
						<!-- 业务信息 -->
						<%@include file="/jsp/common_yw_include.jsp"%>		
						<div class="business-manwife">垫款信息</div>
				           	<div class="business-padding" style="padding-bottom: 0px;">
						        <table cellpadding="0" cellspacing="0" border="0" class="infor-table">
						        <input id="feesId" name="feesId" type="hidden" value="${ywFees.id }"/>
								 <tr>	
									<td align="right">
										<label class="control-label np">开户银行：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.nameBankReceiver}</div>
									</td>
									<td align="right">
										<label class="control-label np">收款人/单位：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.accountNameReceiver}</div>
									</td>
								</tr>
								
								<tr>
									<td align="right">
										<label class="control-label np">结算方式：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.typeBalanceDisplay}</div>
									</td>
									<td align="right">
										<label class="control-label np">账号：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.accounnNoReceiver}</div>
									</td>
								</tr>
								
								<tr>	
									<td align="right">
										<label class="control-label np">第一年投保：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.objectInsure1}</div>
									</td>
									
									<td align="right">
										<label class="control-label np">第一年收益：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.objectEarnings1}</div>
									</td>
								</tr>
								
								<tr>	
									<td align="right">
										<label class="control-label np">第二年投保：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.objectInsure2}</div>
									</td>
									
									<td align="right">
										<label class="control-label np">第二年收益：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.objectEarnings2}</div>
									</td>
								</tr>
								
								<tr>	
									<td align="right">
										<label class="control-label np">第三年投保：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.objectInsure3}</div>
									</td>
									
									<td align="right">
										<label class="control-label np">第三年收益：</label>
									</td>
									<td>
										<div class="control-div np">${ywFees.objectEarnings3}</div>
									</td>
								</tr>
								
							</table>
						</div>
						<div class="padding-nono" style="padding-top: 0px;">	
							<table cellpadding="0" cellspacing="0" border="0" class="thead-table padding-wanggeb">
								<thead class="thead-a">
									<tr>
										<th class="warn-red-bold">实际贷款额</th>
										<th class="warn-red-bold">签约贷款额</th>
										<c:if test="${!empty fundItems_ }">
											<c:forEach items="${fundItems_ }" var="fundItem_" varStatus="status">
												<th class="warn-red-bold">${fundItem_.name }</th>
											</c:forEach>
										</c:if>
									</tr>
								</thead>
								<tbody class="tbody-a">
									<tr>
										<td class="zxyjred">
											<input class="tbody-control" id="amount"  readonly="readonly" value="${ywFees.amount }"/>
										</td>
										<td class="zxyjred">
											<input class="tbody-control" id="sign_loan_amount"  readonly="readonly" value="${ywFees.signLoanAmount }" />
										</td>
										<c:if test="${!empty fundItems_ }">
											<c:forEach items="${fundItems_ }" var="fundItem_" varStatus="status">
												<td class="zxyjred"><fmt:formatNumber type="number" value="${empty fundItem_.feeCount ? 0 : fundItem_.feeCount}" pattern="0.00" maxFractionDigits="2" /></td>
											</c:forEach>
										</c:if>
									</tr>
								</tbody>
							</table>
							
							<c:choose>
								<c:when test="${!empty fundItems }">
									<c:set var="tBodyCount" value="${tBodyCount}" />
									<table cellpadding="0" cellspacing="0" border="0" class="thead-table">
										<c:forEach var="placeholder" items="${loopPlaceholders }" varStatus="holderStatus">
											<c:forEach items="${fundItems }" var="cwFundItem" varStatus="status" begin="${holderStatus.index * 7 }" end="${(holderStatus.index + 1) * 7 - 1}">
												<c:if test="${status.index % 7 == 0 }">
														<thead class="thead-a">
										    				<tr>
												</c:if>
												<th
													<c:if test="${cwFundItem.key == '03'}"> style="color:#FC1515;"</c:if>
													<c:if test="${cwFundItem.key == '25'}"> style="color:#FC1515;"</c:if>>${cwFundItem.name }
												</th>
												<c:if test="${status.index % 7 == 6  || status.last}">
															</tr>
														</thead>
												</c:if>
											</c:forEach>
											<c:forEach items="${fundItems }" var="cwFundItem" varStatus="status" begin="${holderStatus.index * 7 }" end="${(holderStatus.index + 1) * 7 - 1}">
												<c:if test="${status.index % 7 == 0 }">
														<tbody class="tbody-a">
										    				<tr>
												</c:if>
												<td <c:if test="${cwFundItem.key == '03'}"> style="color:#FC1515;"</c:if>
													<c:if test="${cwFundItem.key == '25'}"> style="color:#FC1515;"</c:if>><input  class="tbody-control" type="text" readonly="readonly" value='<fmt:formatNumber type="number" value="${cwFundItem.feeCount }" pattern="0.00" maxFractionDigits="2"/>' /></td>
												<c:if test="${status.index % 7 == 6  || status.last}">
															  </tr>
										 				</tbody>
												</c:if>
											</c:forEach>
										</c:forEach>
									</table>
								</c:when>
								<c:otherwise>
									没有收费项目
								</c:otherwise>
							</c:choose>
							<table cellpadding="0" cellspacing="0" border="0" class="thead-table" style="width: 14%">
								<tbody class="tbody-a">
									<tr>
										<td class="npb style-red">合计</td>
										<td id="totalFee"><fmt:formatNumber type="number" value="${fundTotal.feeCount }" pattern="0.00" maxFractionDigits="2" /></td>
									</tr>
								</tbody>
							</table>
						</div>	
						 <div class="business-manwife">返利信息</div>
						       <div class="business-padding">
							    <table cellpadding="0" cellspacing="0" border="0" class="infor-table">
									 <tr>
										<td align="right">
											<label class="control-label np">经销商返利：</label>
										</td>
										<td> 
											<div class="control-div np" id=""><fmt:formatNumber type="number" value="${empty ywFees.rebateDealer ? 0 : ywFees.rebateDealer}" pattern="0.00" maxFractionDigits="2"/></div>
										</td>	
										<td align="right">
											<label class="control-label np">分公司展业费：</label>
										</td>
										<td>
											<div class="control-div np" id=""><fmt:formatNumber type="number" value="${empty ywFees.rebateProvince ? 0 : ywFees.rebateProvince}" pattern="0.00" maxFractionDigits="2"/></div>
										</td>
									</tr>	
									<tr>
										<td align="right">
											<label class="control-label np">区域&业务员展业费：</label>
										</td>
										<td> 
											<div class="control-div np" id=""><fmt:formatNumber type="number" value="${empty ywFees.rebateArea ? 0 :  ywFees.rebateArea}" pattern="0.00" maxFractionDigits="2"/></div>
										</td>	
										<td align="right">
											<label class="control-label np">返利方式：</label>
										</td>
										<td>
											<div class="control-div np" id="">${empty ywFees.rebateTypeDisplay ? '-' : ywFees.rebateTypeDisplay}</div>
										</td>
									</tr>	
								</table>
							</div>
							<div class="business-manwife">业务信息</div>
							<div class="business-padding">
							    <table cellpadding="0" cellspacing="0" border="0" class="infor-table">
									 <tr>
										<td align="right">
											<label class="control-label np">业务来源人：</label>
										</td>
										<td>
											<div class="control-div np" id="">${ywBusinessDetail.salesmanName }</div>
										</td>	
										<td align="right">
											<label class="control-label np">业务经办人：</label>
										</td>
										<td>
											<div class="control-div np" id="">${current_user_key.uname }</div>
										</td>
										<td align="right">
											<label class="control-label np">业务办理时间：</label>
										</td>
										<td>
											<div class="control-div np" id=""><fmt:formatDate value='${ywBusinessDetail.submitTime }' pattern='yyyy-MM-dd'/></div>
										</td>
									</tr>
								</table>
							</div>
						<!-- 当前经办人 -->
    					<%@include file="/jsp/comm_current_person_include.jsp"%>
					</form>
                 </div>
             </div>
             <div id="tab-2" class="tab-pane">
             <div class="business-man">业务流程</div>
				<div class="business-padding" id="">
					<table class="yw-course">
						  <thead>
						    <tr>
						        <th class="splztab bg-grey">按揭日报表</th>
						        <th class="splztab bg-green">申请垫资</li>
			           			<th class="splztab">财务审核1</th>
			           			<th class="splztab">财务审核2</th>
			           			<th class="splztab">财务垫款</th>
			           			<th class="splztab">垫款调整A</th>
			           			<th class="splztab">申请垫款调整Ｂ</th>
			           			<th class="splztab">垫款调整Ｂ审核</th>
			           			<th class="splztab">垫款调整Ｂ</th>
			           			<th class="splztab">财务退款</th>
						    </tr>
						  </thead>
					</table>
				</div>
				<div class="business-manwife">申请垫资</div>
                 <div class="panel-body panel-bodyb">
                 	  <form class="" id="commentForm">
                 	  	<div class="padding-nono">
						   <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
								 <tr>
								 	<input id="fundApplyId" name="fundApplyId" type="hidden" value="${ywFundApply.id }"/>
									<td align="right">
										<label class="control-label np">提车时间：</label>
									</td>
									<td>
										<input id="dateFist" name="dateFist" required="required" placeholder="预计提车时间(必填)" class="laydate-icon form-control" value="<fmt:formatDate value='${ywFundApply.dateFist }' pattern='yyyy-MM-dd'/>" />
									</td>
								</tr>
							</table>
							<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
                       			<tr>
                       				<td align="right" valign="top">
										<label class="control-label np">信息备注：</label>
									</td>
                       				<td align="right">
                             		 	<textarea class="form-control" cols="80" rows="3" id="remarks" name="remarks" placeholder="信息备注">${ywFundApply.remarks }</textarea>
                       				</td>
                       			</tr>
                       			</tr>
                       			<tr>
                       				<td align="right" valign="top"> &nbsp; </td>
								</tr>	
                       			<tr>
                       				<td align="right" valign="top"> &nbsp; </td>
									<td align="left" valign="top">
										<button type="button" class="btn dpbtn_blue" onclick="save();">申请垫资</button>
									</td>
                       			</tr>
							</table>
						</div>
						<!-- 当前经办人 -->
    					<%@include file="/jsp/comm_current_person_include.jsp"%>
                 	  </form>
                 </div>
             </div>
         </div>
	</div>
</div>	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
	
	<!-- summernote -->
 	<%-- <%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%> --%>
    
    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    
    
    <script type="text/javascript"></script>
    <!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
	    $(function(){
	    	$("#commentForm").validate({
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        }); 
	    });
	    jQuery(function($) {
	    	var start = {
	    			  elem: '#dateFist', 
	  		          event: 'focus' ,
	    			  format: 'YYYY-MM-DD',
	    			  min: laydate.now(), //设定最小日期为当前日期
	    			  max: '2099-06-16', //最大日期
	    			  istime: false,
	    			  istoday: false/* ,
	    			  choose: function(datas){
	    			     end.min = datas; //开始日选好后，重置结束日的最小日期
	    			     end.start = datas; //将结束日的初始值设定为开始日
	    			  } */
	    			};
	    	
	    	/* var end = {
	    			  elem: '#dateLast', 
	  		          event: 'focus' ,
	    			  format: 'YYYY-MM-DD',
	    			  min: laydate.now(),
	    			  max: '2099-06-16',
	    			  istime: true,
	    			  istoday: false,
	    			  choose: function(datas){
	    			    start.max = datas; //结束日选好后，重置开始日的最大日期
	    			  }
	    			}; */
	    	
	    	laydate(start);
	    	/* laydate(end); */
	    });
	    
	  //申请垫资
		function save(){
			//询问框
			var validstatus = $("#commentForm").valid();
		    if(validstatus){
				var customerName = $('#customerName').text();
				var dateFist = $('#dateFist').val();
				/* var dateLast=  $('#dateLast').val(); */
				
				//layer.confirm('为客户 ' + customerName + ' 申请垫资，并规定于 ' + dateFist + ' 到  ' + dateLast + ' 之间提车', {
				layer.confirm('为客户 ' + customerName + ' 申请垫资，并规定于 ' + dateFist + ' 之前提车', {
				  title:'确认申请垫资',
				  btn: ['确认','返回修改'] //按钮
				}, function(){
					layer.closeAll();
					var data = {};
					var id = $('#fundApplyId').val();
					data.busiId = $('#busiId').val();
					data.feesId = $('#feesId').val();
					data.cusId = $('#customerId').val();
					data.dateFist = dateFist;
					/* data.dateLast = dateLast; */
					data.remarks=$('#remarks').val();
					data.id = id;
					var url = '${basePath}/YwFundApplyController/applyFund';
					$.dpAjax({
		        		show:true,
		 	    		url:url,
		 	    		data:data,
		     			success: function(datas){
			     			  if(datas.flag == "100100")
		 					  {
			     				 layer.msg('申请垫资保存成功', {icon: 6,time:3000});
			     				 setTimeout(function(){
			     					location.href='${basePath}/web/system/yw/applyLoan.jsp'; 
			     				 },3000);
		 						 return;
		 					  }
		 					  if(datas.flag == "100200")
		 	                  {
		 						  $.fn.showDatas({"datas":datas});
		 	                	  return;
		 	                  }
		 					  layer.msg(datas.message, {icon: 2});
		                 }
		 	    	});
				}, function(){
					layer.closeAll();
				});
			}
		}
	  
    </script>
</body>
</html>
